# ==============================================================================
# Build libpappradio as a shared library
# ==============================================================================

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

PROJECT( LIBPAPPRADIO )

# update current module path, so we have some FindWhatever.cmake-files at hand

SET( CMAKE_MODULE_PATH 
     "${CMAKE_MODULE_PATH}"
     "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )

# Set the sources and headers(!) so if using an IDE (like codeblocks or VSC++)
# we can see both...

SET( SOURCES
     pappradio.cpp 
     pappradio.hpp )

# We would like to build a C++-library out of our source-files. REMARK: you should
# allways(!) use the same compiler for your main target as the one this lib is
# build with.

ADD_LIBRARY( pappradio  
             ${SOURCES} )

# ... and of course we need to link to something...

TARGET_LINK_LIBRARIES( pappradio 
                       hidapi )

# we need to copy the fqdata to our build-directories... For VSC++ this is somewhat
# awkward, as we do not know if we are to build a Release or a Debug version. So we
# just copy the files to both directories in this case...

IF( WIN32 )
    IF( MSVC )
        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/data/fqdata.dat
                       ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}/fqdata.dat COPYONLY)
        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/data/fqdata.dat
                       ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}/fqdata.dat COPYONLY)
    ELSE( MSVC)
        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/data/fqdata.dat
                       ${CMAKE_CURRENT_BINARY_DIR}/fqdata.dat COPYONLY)
    ENDIF( MSVC )
ELSE()
    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/data/fqdata.dat
                   ${CMAKE_CURRENT_BINARY_DIR}/fqdata.dat COPYONLY)
ENDIF()

# if we ever want to install the files to somewhere it might be a good idea to mark the
# files which should be installed and to were they should be installed.
#
# For windows we assume this directory to be c:/Program Files (x86)/PappSDR/.
# For all other plattforms we assume this to be /usr/bin/PappSDR and /usr/share/PappSDR.
# (Or /usr/lib/ for shared libraries)
# We do *not* want to install the testbed-app.

#IF( WIN32 )
#    INSTALL( FILES       "${CMAKE_CURRENT_SOURCE_DIR}/data/fqdata.dat" 
#             DESTINATION "c:/Program\ Files\ (x86)/PappSDR/" )
#    #INSTALL( TARGETS     pappradio 
#    #         DESTINATION "c:/Program\ Files\ (x86)/PappSDR/" )
#ELSE()
#    INSTALL( FILES       "${CMAKE_CURRENT_SOURCE_DIR}/data/fqdata.dat" 
#             DESTINATION "/usr/share/PappSDR" )
#    #INSTALL( TARGETS     pappradio 
#    #         DESTINATION "/usr/lib" )
#ENDIF()
